package net.java.mediasystems.database.core.model;

import java.io.Serializable;

import javax.persistence.Column;
import javax.persistence.Embeddable;

@Embeddable
public class MediaItemToGenreAssociationId implements Serializable {

	private static final long serialVersionUID = 6179679500971390469L;

	@Column(name = "MEDIA_ITEM_ID", nullable = false)
	private Long mediaItemId;
	
	@Column(name = "GENRE_ID", nullable = false)
	private Long genreId;
	
	@Override
	public boolean equals(Object obj) {
		if (obj == null || !(obj instanceof MediaItemToGenreAssociationId)) {
			return false;
		}
		MediaItemToGenreAssociationId other = (MediaItemToGenreAssociationId) obj;
		if (this.mediaItemId == null || this.genreId == null) {
			return false;
		}
		if (other.mediaItemId == null || other.genreId == null) {
			return false;
		}
		return this.mediaItemId.equals(other.mediaItemId)
				&& this.genreId.equals(other.genreId);
	}
	
	@Override
	public int hashCode() {
		if (this.mediaItemId == null || this.genreId == null) {
			return super.hashCode();
		}
		return (this.getClass().getName() + this.mediaItemId + this.genreId).hashCode();
	}

	@Override
	public String toString() {
		return "MediaItemToGenreAssociationId [mediaItemId=" + this.mediaItemId + ", genreId="
				+ this.genreId + "]";
	}

	public Long getMediaItemId() {
		return mediaItemId;
	}

	public void setMediaItemId(Long mediaItemId) {
		this.mediaItemId = mediaItemId;
	}

	public Long getGenreId() {
		return genreId;
	}

	public void setGenreId(Long genreId) {
		this.genreId = genreId;
	}
}
